{include file="header.html"}
<body>

<div class="navBar">
	<a class="left" href="http://kf.aqrcm.com/chat?locale=zh-cn&name=6kKf6aoo00oq5rap6hipMzY1Y3B4WQO0O0OO0O0O"><i class="service"></i></a>
	<div class="titleView">商富商城</div>
	<a class="right" href="?tpl=search"><i class="search"></i></a>
</div>

<div class="home-index main-padding-top main-padding-bottom">
	<div class="pullRefresh">
		{if count($data.flashes)>0}
		<div class="pageView">
			<div class="slide">
				<ul>
					{foreach from=$data.flashes name=g item=g}
					<li ad_type="{$g->ad_type}" ad_content="{$g->ad_content}" pic="{$g->pic}"></li>
					{/foreach}
				</ul>
			</div>
			<div class="pager"></div>
		</div>
		{/if}
		
		<div class="cate">
			<a href="wap.php?app=goods&act=index&ext_property=5"><div class="ico1"></div><span>疯狂折扣</span></a>
			<a href="wap.php?app=goods&act=index&ext_property=2"><div class="ico3"></div><span>热卖榜</span></a>
			{if count($data.icons)>0}
				{foreach from=$data.icons name=icon item=icon}
				<a href="wap.php?app=goods&act=index&integral=1&category_id={$icon->id}"><div class="ico2" style="background-image:url({$icon->home_icon});"></div><span>{$icon->home_name}</span></a>
				{/foreach}
			{/if}
			
		</div>
		
		<div class="tip ge-top"><i></i>优选精品</div>
		{if count($data.yxjp)>0}
		<ul class="list ads">
			{foreach from=$data.yxjp name=g item=g}
			<li ad_type="{$g->ad_type}" ad_content="{$g->ad_content}" pic="{$g->pic}"></li>
			{/foreach}
		</ul>
		{/if}
	</div>
</div>

<div class="footer">
	<a class="ico1 this" href="wap.php"></a>
	<a class="ico2" href="wap.php?app=category&act=index"></a>
	<a class="ico5" href="wap.php?app=member&act=index"></a>
</div>

<script>
var offset = $('.pullRefresh .list > li').length;
function createHtml(g){
	var html = '<li ad_type="'+g.ad_type+'" ad_content="'+g.ad_content+'" pic="'+g.pic+'"></li>';
	offset++;
	return html;
}
function resize(){
	$('.pageView').autoHeight(320, 137);
	$('.pageView li').css({ width:$('.pageView').width(), height:$('.pageView').height() });
	$('.pageView').touchmove({
		pager : '.pager',
		drag : true,
		auto : 4000,
		autoWait : 4000,
		complete : function(){
			$('.pager').css('margin-left', -$('.pager').width()/2);
			setAds('.pageView .slide li');
		}
	});
	$('.ads li').autoHeight(320, 103);
}
$(window).resize(resize);
$(function(){
	resize();
	setAds('.pageView .slide li, .home-index .ads li');
	$('.home-index').height($.window().height-$('.home-index').padding().top-$('.home-index').padding().bottom);
	$('.pullRefresh').pullRefresh({
		header : true,
		footer : true,
		footerNoMoreText : '- END -',
		refresh : function(fn){
			var _this = this;
			offset = 0;
			$.getJSON('api.php?app=home&act=index', function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data.yxjp))for(var i=0; i<json.data.yxjp.length; i++)html += createHtml(json.data.yxjp[i]);
				_this.find('.list').html(html);
				setAds('.list li');
				fn();
			});
		},
		load : function(fn){
			var _this = this;
			$.getJSON('api.php?app=home&act=index', { offset:offset }, function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data.yxjp))for(var i=0; i<json.data.yxjp.length; i++)html += createHtml(json.data.yxjp[i]);
				_this.find('.list').append(html);
				setAds('.list li');
				fn();
			});
		}
	});
});
</script>
{include file="footer.html"}
